﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Demo3Layer_Payment.Data_Tranfer_Object;
using Demo3Layer_Payment.Bussines_Logic_Layer;

namespace Demo3Layer_Payment
{
    public partial class frmPayment : Form
    {

        #region"Attribute"
        private CustomersBLO objCustomersBLO;
        private CustomersDTO objCustomersDTO;
        #endregion

        #region"Method"
        public frmPayment()
        {
            InitializeComponent();
            objCustomersBLO = new CustomersBLO();
            objCustomersDTO = new CustomersDTO();
        }
        /// <summary>
        /// Button  Insert
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInsert_Click(object sender, EventArgs e)
        {
            objCustomersDTO.StrCustomersID = "";
            objCustomersDTO.StrCustomersName = txtName.Text.Trim();
            objCustomersDTO.StrCustomersPhone = txtPhone.Text.Trim();
            objCustomersDTO.StrCustomersEmail = txtEmail.Text.Trim();
            objCustomersDTO.StrCustomersAddress = txtAddress.Text.Trim();
            objCustomersDTO.DateCustomersBirthday = dtBirthday.Value.Date;
            bool flag=objCustomersBLO.InsertCustomers();
            if (flag == false)
                MessageBox.Show("Error!!!");
        }
        #endregion

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            DialogResult r = MessageBox.Show("Are you sure exit?", "Program", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (r == DialogResult.Yes)
            {
                this.Close();
                this.Dispose();
            }
            else
            {
                ;
            }
        }

        private void dtgvInfoCustomers_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //objCustomersDTO.StrCustomersID = dtgvInfoCustomers.CurrentRow.Cells[0].Value.ToString();
            //txtName.Text = objCustomersDTO.StrCustomersName.ToString().Trim();
            //txtPhone.Text = objCustomersDTO.StrCustomersPhone.ToString().Trim();
            //txtAddress.Text = objCustomersDTO.StrCustomersAddress.ToString().Trim();
            //txtEmail.Text = objCustomersDTO.StrCustomersEmail.ToString().Trim();
            //demo use bingding data
        }

        private void frmPayment_Load(object sender, EventArgs e)
        {
            dtgvInfoCustomers.Refresh();
            dtgvInfoCustomers.DataSource = objCustomersBLO.SelectAllCustomers();
            dtgvInfoCustomers.AutoResizeColumns();
        }

       

      
    }
}
